package com.xinchao.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.xinchao.core.constant.PageConstant;
import com.xinchao.dao.DeviceUpgradeMessageMapper;
import com.xinchao.model.DeviceUpgradeMessage;
import com.xinchao.model.vo.DeviceUpgradeMessageVO;
import com.xinchao.service.DeviceUpgradeMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 终端升级消息
 *
 * @author linqiang
 * @date 2018-08-10 14:25
 */
@Service(value = "deviceUpgradeMessageService")
public class DeviceUpgradeMessageServiceImpl implements DeviceUpgradeMessageService {

    @Autowired
    private DeviceUpgradeMessageMapper deviceUpgradeMessageMapper;

    /**
     * 新增
     *
     * @param record 新增的数据
     * @return 影响行数
     */
    @Override
    public int insert(DeviceUpgradeMessage record) {
        return deviceUpgradeMessageMapper.insert(record);
    }

    /**
     * 分页查询
     *
     * @param currentCity 当前城市
     * @return Page<DeviceUpgradeMessage>
     */
    @Override
    public Page<DeviceUpgradeMessageVO> listByPage(String currentCity, Integer pageNum, Integer pageSize) {
        pageNum = pageNum == null ? PageConstant.DEFAULT_PAGE_NUM : pageNum;
        pageSize = pageSize == null ? PageConstant.DEFAULT_PAGE_SIZE : pageSize;
        PageHelper.startPage(pageNum, pageSize);
        return deviceUpgradeMessageMapper.listByPage(currentCity);
    }
}
